
package org.feerepository.client.components;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.VerticalPanel;
import java.util.HashMap;
import org.feerepository.client.EventListener;
import org.feerepository.client.request.HttpRequestFactory;
import org.feerepository.client.views.IServiceMapView;

public class ServiceMapPanel extends Composite implements IServiceMapView, EventListener
{
    private VerticalPanel content = new VerticalPanel();
    private Label title = new Label();
    private FlexTable serviceTab = new FlexTable();

    public ServiceMapPanel()
    {
        content.add(this.title);
        content.add(this.serviceTab);
        serviceTab.addStyleName("serviceTab-FlexTable");
        initWidget(content);

    }

    public void progpertiesChanged(HashMap<String, Object> properties) {
      String name = (String)properties.get("SELECTED_JURISDICTION");
      Integer id = (Integer)properties.get("SELECTED_JURISDICTION_ID");
      HttpRequestFactory fact = new HttpRequestFactory();

        fact.sendGetServicesForJurisdictionRequest(id.intValue());
            title.setText(name);
        serviceTab.clear();
         row = 0;

    }

    public void propertyChanged(String name, Object value)
    {
        
        HttpRequestFactory fact = new HttpRequestFactory();

        fact.sendGetServicesForJurisdictionRequest(1);
        if(name.equals("SELECTED_JURISDICTION"))
            title.setText(value.toString());
        serviceTab.clear();
         row = 0;
    }
    private String currentService;
    private int row = 0;

    public void addService(String serviceName)
    {
        this.currentService = serviceName;
        serviceTab.setWidget(row++, 0, new Label(serviceName));
    }

}
